﻿using System;
using System.Windows;

namespace WickedFlame.VecDraw
{
    public class VecDrawApplication : Application
    {
        public MainGui gui { get; private set; }

        public VecDrawApplication()
            : base()
        { }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            try
            {
                gui = new MainGui();
                ProcessArgs(e.Args, true);

                gui.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        public void ProcessArgs(string[] args, bool firstInstance)
        {
            if (args.Length > 0)
                gui.ImportFile(args[0]);
        }
    }
}
